package com.mzy.linear_struct.subject;

import javax.swing.tree.TreeNode;
import java.util.LinkedList;
import java.util.List;

/**
 * @Author: codermzy
 * @Date: 2024/04/26/下午6:27
 * @Description:
 */
public class 二叉树的中序遍历94 {


    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }


    static class Solution {
        public List<Integer> inorderTraversal(TreeNode root) {
            LinkedList<Integer> list = new LinkedList<>();
            traversal(root, list);
            return list;
        }

        public void traversal(TreeNode root, List<Integer> list) {
            if (root == null) {
                return;
            }
            traversal(root.left, list);
            list.add(root.val);
            traversal(root.right, list);
        }

    }

    public static void main(String[] args) {
        // new Solution().inorderTraversal()
    }
}
